//
//  JoinCourseCollectionViewCell.m
//  ECBBusinessCamp
//
//  Created by rimi on 16/6/28.
//  Copyright © 2016年 邓毕华. All rights reserved.
//

#import "JoinCourseCollectionViewCell.h"

#define FONT_COLOR RGB_COLOR(164, 164, 164, 1)
#define FONT_SIZE 25

@interface JoinCourseCollectionViewCell ()

@property (nonatomic, strong) UIView * boxView; // 灰色边框

@end

@implementation JoinCourseCollectionViewCell

#pragma mark 🌷🌷🌷life cycle🌷🌷🌷
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        // 添加视图
        [self addSubview:self.boxView];
        [self addSubview:self.teacherNameLabel];
        [self addSubview:self.countLessionLabel];
        [self addSubview:self.studentsLabel];
        [self addSubview:self.priceLabel];
        [self addSubview:self.starsView];
        [self addSubview:self.discussLabel];
        [_boxView addSubview:self.videoNameLabel];
        [_boxView addSubview:self.videoCoverImageView];
        
        // 自动布局
        [_boxView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(self);
            make.height.equalTo(self).multipliedBy(0.45);
            make.centerX.equalTo(self);
            make.top.offset(0);
        }];
        [_teacherNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_boxView);
            make.top.equalTo(_boxView.mas_bottom).offset(5);
        }];
        [_countLessionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_teacherNameLabel);
            make.right.offset(0);
        }];
        [_studentsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_boxView);
            make.centerY.equalTo(self).multipliedBy(1.5);
        }];
        [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_studentsLabel);
            make.right.offset(0);
        }];
        [_starsView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(self).multipliedBy(0.5);
            make.height.equalTo(self).multipliedBy(0.18);
            make.left.equalTo(_boxView);
            make.bottom.offset(0);
        }];
        [_discussLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_starsView);
            make.right.offset(0);
        }];
        [_videoNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_boxView);
            make.left.offset(0);
        }];
        [_videoCoverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(_boxView).multipliedBy(0.45);
            make.height.equalTo(_boxView);
            make.centerY.equalTo(_boxView);
            make.right.offset(0);
        }];
        
    }
    return self;
}

#pragma mark 🌷🌷🌷getters and setters🌷🌷🌷
- (UIView *)boxView {
    if (!_boxView) {
        _boxView = [[UIView alloc] init];
        _boxView.layer.borderColor = RGB_COLOR(164, 164, 164, 1).CGColor;
        _boxView.layer.borderWidth = 1;
    }
    return _boxView;
}
- (UILabel *)videoNameLabel {
    if (!_videoNameLabel) {
        _videoNameLabel = [[UILabel alloc] init];
        _videoNameLabel.textColor = FONT_COLOR;
        _videoNameLabel.font = [UIFont systemFontOfSize:FONT_SIZE];
    }
    return _videoNameLabel;
}
- (UIImageView *)videoCoverImageView {
    if (!_videoCoverImageView) {
        _videoCoverImageView = [[UIImageView alloc] init];
        
    }
    return _videoCoverImageView;
}
- (UILabel *)teacherNameLabel {
    if (!_teacherNameLabel) {
        _teacherNameLabel = [[UILabel alloc] init];
        _teacherNameLabel.font = [UIFont systemFontOfSize:23];
    }
    return _teacherNameLabel;
}
- (UILabel *)countLessionLabel {
    if (!_countLessionLabel) {
        _countLessionLabel = [[UILabel alloc] init];
        _countLessionLabel.font = [UIFont systemFontOfSize:23];
    }
    return _countLessionLabel;
}
- (UILabel *)studentsLabel {
    if (!_studentsLabel) {
        _studentsLabel = [[UILabel alloc] init];
        _studentsLabel.font = [UIFont systemFontOfSize:20];
        _studentsLabel.textColor = FONT_COLOR;
    }
    return _studentsLabel;
}
- (UILabel *)priceLabel {
    if (!_priceLabel) {
        _priceLabel = [[UILabel alloc] init];
        _priceLabel.font = [UIFont systemFontOfSize:20];
        _priceLabel.textColor = FONT_COLOR;
    }
    return _priceLabel;
}
- (UIView *)starsView {
    if (!_starsView) {
        _starsView = [[UIView alloc] init];
    }
    return _starsView;
}
- (UILabel *)discussLabel {
    if (!_discussLabel) {
        _discussLabel = [[UILabel alloc] init];
        _discussLabel.font = [UIFont systemFontOfSize:20];
        _discussLabel.textColor = FONT_COLOR;
    }
    return _discussLabel;
}

@end
